﻿using System;
using System.Collections.Generic;
using BrnMall.Core;

namespace QIDong.WeApp.Models
{
    /// <summary>
    /// 
    /// </summary>
    public class ProductListOutDto
    {
        private int _pid; //商品id
        private string _psn = ""; //商品货号
        private int _cateid = 0; //商品分类id
        private int _brandid = 0; //商品品牌id
        private int _storeid = 0; //店铺id
        private int _storecid = 0; //店铺分类id
        private int _storestid = 0; //店铺配送模板id
        private int _skugid = 0; //商品sku组id
        private string _name = ""; //商品名称

        /// <summary>
        /// 商品id
        /// </summary>
        public int Pid
        {
            set { _pid = value; }
            get { return _pid; }
        }

        /// <summary>
        /// 商品货号
        /// </summary>
        public string PSN
        {
            set { _psn = value.TrimEnd(); }
            get { return _psn; }
        }

        /// <summary>
        /// 商品分类id
        /// </summary>
        public int CateId
        {
            set { _cateid = value; }
            get { return _cateid; }
        }

        /// <summary>
        /// 商品品牌id
        /// </summary>
        public int BrandId
        {
            set { _brandid = value; }
            get { return _brandid; }
        }

        /// <summary>
        /// 店铺id
        /// </summary>
        public int StoreId
        {
            set { _storeid = value; }
            get { return _storeid; }
        }

        /// <summary>
        /// 店铺分类id
        /// </summary>
        public int StoreCid
        {
            set { _storecid = value; }
            get { return _storecid; }
        }

        /// <summary>
        /// 店铺配送模板id
        /// </summary>
        public int StoreSTid
        {
            set { _storestid = value; }
            get { return _storestid; }
        }

        /// <summary>
        /// 商品sku组id
        /// </summary>
        public int SKUGid
        {
            set { _skugid = value; }
            get { return _skugid; }
        }

        /// <summary>
        /// 商品名称
        /// </summary>
        public string Name
        {
            set { _name = value; }
            get { return _name; }
        }

        /// <summary>
        /// 商品商城价
        /// </summary>
        public decimal ShopPrice { set; get; } = 0M;

        /// <summary>
        /// 商品市场价
        /// </summary>
        public decimal MarketPrice { set; get; } = 0M;

        /// <summary>
        /// 商品成本价
        /// </summary>
        public decimal CostPrice { set; get; } = 0M;

        /// <summary>
        /// 0代表上架，1代表下架，2代表回收站
        /// </summary>
        public int State { set; get; } = 0;

        /// <summary>
        /// 商品是否精品
        /// </summary>
        public int IsBest { set; get; } = 0;

        /// <summary>
        /// 商品是否热销
        /// </summary>
        public int IsHot { set; get; } = 0;

        /// <summary>
        /// 商品是否新品
        /// </summary>
        public int IsNew { set; get; } = 0;

        /// <summary>
        /// 商品排序
        /// </summary>
        public int DisplayOrder { set; get; } = 0;

        /// <summary>
        /// 商品重量
        /// </summary>
        public int Weight { set; get; } = 0;

        /// <summary>
        /// 商品展示图片
        /// </summary>
        public string ShowImg { set; get; } = "";

        /// <summary>
        /// 销售数
        /// </summary>
        public int SaleCount { set; get; } = 0;

        /// <summary>
        /// 访问数
        /// </summary>
        public int VisitCount { set; get; } = 0;

        /// <summary>
        /// 评价数
        /// </summary>
        public int ReviewCount { set; get; } = 0;

        /// <summary>
        /// 评价星星1
        /// </summary>
        public int Star1 { set; get; } = 0;

        /// <summary>
        /// 评价星星2
        /// </summary>
        public int Star2 { set; get; } = 0;

        /// <summary>
        /// 评价星星3
        /// </summary>
        public int Star3 { set; get; } = 0;

        /// <summary>
        /// 评价星星4
        /// </summary>
        public int Star4 { set; get; } = 0;

        /// <summary>
        /// 评价星星5
        /// </summary>
        public int Star5 { set; get; } = 0;

        /// <summary>
        /// 商品添加时间
        /// </summary>
        public DateTime AddTime { set; get; } = DateTime.Now;

        /// <summary>
        /// 折扣价
        /// </summary>
        public decimal DiscountPrice { get; set; } = 0M;

        /// <summary>
        /// 
        /// </summary>
        public int StockNumber { get; set; } = 0;

        /// <summary>
        /// 轮播头图
        /// </summary>
        public string BannerImg { get; set; }

        
        
        
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public int GetStarLevel()
        {
            int goodStars = Star1 + Star2 + Star3;
            int allStars = goodStars + Star4 + Star5;

            if (allStars == 0)
                return 100;
            return goodStars * 100 / allStars;
        }
    }
}
    
